<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
    <div>
        <p></p>
    </div>
    <button id="btn">按钮</button>
    <script>
    // 4 实现红绿灯功能 页面中有一个圆形的灯 10秒变红 10秒变黄 10秒变绿 再变红 再变黄 再变绿 重复此过程  
        var box = document.querySelector("div")
        box.style.width = "200px"
        box.style.height = "200px"
        box.style.border = "10px solid #444"
        box.style.position = "fixed"
        box.style.top = "0"
        box.style.left = "0"
        box.style.right = "0"
        box.style.bottom = "0"
        box.style.margin = "auto"

        var circle = box.querySelector("p")
        circle.style.width = "200px"
        circle.style.height = "200px"
        circle.style.borderRadius = "50%"
        circle.style.background = "red"
        function fn(){
            setTimeout(function(){
                circle.style.background = "yellow"
            }, 1000);
            setTimeout(function(){
                circle.style.background = "green"
            }, 2000);
            setTimeout(function(){
                circle.style.background = "red"
                fn()    
            }, 3000);   
        }
        fn()
        console.log(1111);
        console.log(1111);
        console.log(1111);
        console.log(1111);
        console.log(1111);
        console.log(1111);
        console.log(1111);
        console.log(1111);
        console.log(1111);
        console.log(1111);
        console.log(1111);
        console.log(1111);
        console.log(1111);

        // setInterval(function(){
        //     fn()
        // }, 3000);

    </script>
</body>
</html>